package cn.edu.zjicm.wordsnet_d.datapersistent;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import cn.edu.zjicm.wordsnet_d.R;
import cn.edu.zjicm.wordsnet_d.db.WordFactory;
import cn.edu.zjicm.wordsnet_d.synchronize.UserInterface;
import cn.edu.zjicm.wordsnet_d.util.DateTimeUtils;
import cn.edu.zjicm.wordsnet_d.util.LogUtil;
import cn.edu.zjicm.wordsnet_d.util.NightModeUtil;
import cn.edu.zjicm.wordsnet_d.view.CalendarView.State;

public class AppPreference {
	/**
	 * 配置文件的参数名
	 * 
	 */
	public interface AppPreferenceName {
		/**
		 * 单词列表的排序方式,
		 */
		public String SORT_TYPE = "sort_type";

		/**
		 * 是否显示搭配英文
		 */
		public String IS_RELATIONSHIP_EN_SHOW = "is_relation_ship_en_show";

		/**
		 * 是否显示搭配释义
		 */
		public String IS_RELATIONSHIP_CN_SHOW = "is_relation_ship_cn_show";

		/**
		 * 环播间隔
		 */
		public String HUANBO_INTERVAL_INDEX = "huanbo_interval_index";

		/**
		 * 最近一次测试的开始时间
		 */
		public String LAST_TEST_START_TIME = "last_test_start_time";

		/**
		 * 第一次学习新单词书
		 */
		public String FIRST_TIME_STUDY_NEW_BOOK = "first_time_study_new_book";

		/**
		 * 学习计划开始时间
		 */
		public String PLAN_START_DATE = "plan_start_date";

		/**
		 * 学习日期(最近一次进入本软件的日期)
		 */
		public String STUDY_DATE = "study_date";

		/**
		 * 复习日期
		 */
		public String REVIEW_DATE = "review_date";

		/**
		 * 今天已学习新词个数
		 */
		public String TODAY_STUDY_NEW_WORD_COUNT = "today_studey_new_word_count";

		/**
		 * 今天已复习单词个数
		 */
		public String TODAY_REVIEW_WORD_COUNT = "today_review_word_count";

		/**
		 * 今天应复习单词个数
		 */
		public String TODAY_SHOULD_REVIEW_WORD_COUNT = "today_should_review_word_count";

		/**
		 * 自动检查版本更新日期(最近一次自动检测版本更新的日期)
		 */
		public String AUTO_CHECK_UPDATE_DATE = "auto_check_update_date";

		/**
		 * 是否开启学习计划
		 */
		public String STUDY_NOTIFICATION = "study_notification";
		/**
		 * 是否开启锁屏复习单词
		 */
		public String LOCK_SCREEN = "lock_screen";
		/**
		 * 锁屏复习单词个数
		 */
		public String LOCK_SCREEN_WORDS_NUM = "lock_screen_words_num";
		/**
		 * 锁屏背景
		 */
		public String LOCK_SCREEN_WALLPAPER = "lock_screen_wallpaper";
		/**
		 * 通知铃声
		 */
		public String CHOOSE_NOTIFICATION_RING = "CHOOSE_NOTIFICATION_RING";
		/**
		 * 用户头像
		 */
		public String HEAD_PORTRAIT_PIC = "head_protrait_pic";

		/**
		 * 是否从未进入过锁屏界面
		 */
		public String FIRST_VISIT_LOCK_SCREEN = "first_visit_lock_screen";

		/**
		 * 是否第一次使用当前版本
		 * */
		public String FIRST_TIME_USE_THIS_VERSION = "first_time_use_this_version";

		/**
		 * 冲刺模式
		 * */
		public String SPRINT_MODE = "sprint_mode";
		/**
		 * 更名为知米的引导
		 */
		public String TEMP_GUIDE_FOR_RENAME_TO_ZHIMI = "temp_guide_for_rename_to_zhimi";
		/**
		 * 是否显示主页guide
		 */
		public String FIRST_SHOW_GUIDE_STUDYING = "first_show_guide_studying";
		/**
		 * 新浪Access_token
		 */
		public String SINA_ACCESS_TOKEN = "sina_access_token";
		public String SINA_UID = "sina_uid";
		public String SINA_EXPIRES_IN = "sina_expires_in";
		/**
		 * 默认的壁纸
		 */
		public String DEFAULT_WALLPAPER_IMG = "default_wallpaper_img";
		/**
		 * 是否显示设为熟词提示
		 */
		public String SHOW_SET_TO_FAMILIAR_HINT = "show_set_to_familiar_hint";
		/**
		 * 是否显示设为太简单提示
		 */
		public String SHOW_SET_TO_TOO_EASY_HINT = "show_set_to_tooeasy_hint";
		/**
		 * 单词书编号
		 */
		public String BOOK_ID = "book_id";
		/**
		 * 学习单词计划完成时间
		 */
		public String PLAN_END_YEAR = "plan_end_year";
		public String PLAN_END_MONTH = "plan_end_month";
		public String PLAN_END_DAY = "plan_end_day";
		/**
		 * 用户编号
		 */
		public String LOGIN_ID = "login_id";
		public String PASSWORD = "password";
		public String TOKEN = "token";
		public String EXP = "exp"; // Experience point 经验值
		public String EXP_UPDATED = "exp_updated"; // 经验值是否更新到服务器
		// public String MONEY = "money"; // 金钱值
		/**
		 * 所属学校信息
		 */
		public String SCHOOL_ID = "school_id";
		public String SCHOOL_NAME = "school_name";
		/**
		 * 用户昵称
		 */
		public String NICK_NAME = "nick_name";
		// public String EXP = "exp"; //Experience point 经验值
		/**
		 * 同步 sync_vc 同步版本号 sync_time 最近一次同步时间 auto_sync_date_after_startup
		 * 每天第一次启动后自动同步的日期 auto_sync_date_after_study 每天第一次结束学习后自动同步的日期
		 */
		public String SYNC_VC = "sync_vc";
		public String SYNC_TIME = "sync_time";
		public String AUTO_SYNC_DATE_AFTER_STARTUP = "auto_sync_date_after_startup";
		public String AUTO_SYNC_DATE_AFTER_STUDY = "auto_sync_date_after_study";
		/**
		 * 是否是当天第一次开启软件
		 */
		public String FIRST_OPEN_THIS_DAY = "FIRST_OPEN_THIS_DAY";
		/**
		 * 是否显示同步提示
		 */
		public String SHOW_SYNC_HINT = "show_sync_hint";
		/**
		 * 自动检查是否登录日期(最近一次用户是否已登录的日期)
		 */
		/**
		 * 是否显示过推荐知米听力窗口
		 */
		public String SHOW_RECOMMEND_ZHIMI_LISTEN = "show_recommend_zhimi_listen";
		/**
		 * 自动检查是否登录日期(最近一次用户是否已登录的日期)
		 */
		public String AUTO_CHECK_LOGIN_DATE = "auto_check_login_date";
		/**
		 * 选过的单词书
		 */
		public String SELECTED_BOOK_ID = "selected_book_id";
		/**
		 * 升级前旧数据库版本
		 */
		public String OLD_DB_VERSION = "old_db_version";

		/**
		 * 微信用户唯一标示
		 */
		public String WECHAT_UNIONID = "UNIONID_WECHAT";

		/**
		 * 微信用户open_id
		 */
		public String WECHAT_OPENID = "WECHAT_OPENID";
		/**
		 * <<<<<<< .mine 微博用户token
		 */
		public String ACCESS_TOKEN_WEIBO = "ACCESS_TOKEN_WEIBO";
		/**
		 * ======= 第一次使用显示引导页面
		 */
		public String FIRST_GUIDE_PAGE = "first_guide_page";
		/**
		 * ======= 第一次使用显示引导页面 第二次判断
		 */
		public String FIRST_GUIDE_PAGE3 = "first_guide_page3";
		/**
		 * 
		 */
		public String FIRST_GUIDE_PAGE2 = "first_guide_page7";
		/**
		 * >>>>>>> .r1645 是否获取打卡数据
		 */
		public String DOWNLOAD_PUNCH_DATA = "download_punch_data";
		/**
		 * 每个自然天意见反馈提交次数
		 */
		public String FEED_BACK_COUNT = "feed_back_count";
		/**
		 * 意见反馈提交日期
		 */
		public String FEED_BACK_DATE = "feed_back_date";
		/**
		 * 开始界面的广告
		 */
		public String WELCOME_ADS1 = "WELCOME_ADS1";
		public String WELCOME_ADS2 = "WELCOME_ADS2";
		public String WELCOME_ADS3 = "WELCOME_ADS3";
		/**
		 * 开始界面的广告-----优先显示
		 */
		public String WELCOME_ADS_PRIORITY = "WELCOME_ADS_PRIORITY";
		/**
		 * 反馈状态
		 */
		public String HAS_FEEDBACK = "has_feedback";
		/**
		 * 临时保存的反馈，用于没发成功的
		 */
		public String SAVE_FEEDBACK = "save_feedback";
		/**
		 * 巩固熟词的初始化
		 */
		public String INIT_FOR_CONSOLIDATE = "INIT_FOR_CONSOLIDATE";
		/**
		 * 是否自动发音
		 */
		public String AUTO_PRONUNCIATION = "auto_pronunciation";
		/**
		 * 是否是夜间模式
		 */
		public String DAY_NIGHT_MODE = "day_night_mode";
		/**
		 * 记录完成学习计划但是没有打卡的昨天和今天
		 */
		public String NO_PUNCH_DATE = "no_punch_date";
		/**
		 * 单词学习模式
		 */
		public String WORD_STUDY_MODE = "word_study_mode";
		/**
		 * 单词书编号
		 */
		public String WORD_BOOK_INDEX = "word_book_index";
		/**
		 * 学习单词的开始时间
		 */
		public String WORD_START_PLAN_DATE = "word_start_plan_date";
		/**
		 * 学习单词计划完成时间，选择结束时间模式
		 */
		public String WORD_PLAN_END_YEAR = "word_plan_end_year";
		public String WORD_PLAN_END_MONTH = "word_plan_end_month";
		public String WORD_PLAN_END_DAY = "word_plan_end_day";
		/**
		 * 学习单词每天个数，选择每天学习个数模式
		 */
		public String WORD_EVERY_DAY_NUMBER = "word_every_day_number";
		/**
		 * 当前单词书是否在学
		 */
		public String IS_LEARNING_WORD_BOOK = "is_learning_word_book";
		/**
		 * 词组学习模式
		 */
		public String PHRASE_STUDY_MODE = "phrase_study_mode";
		/**
		 * 词组书编号
		 */
		public String PHRASE_BOOK_INDEX = "phrase_book_index";
		/**
		 * 学习词组的开始时间
		 */
		public String PHRASE_START_PLAN_DATE = "phrase_start_plan_date";

		/**
		 * 学习词组计划完成时间
		 */
		public String PHRASE_PLAN_END_YEAR = "phrase_plan_end_year";
		public String PHRASE_PLAN_END_MONTH = "phrase_plan_end_month";
		public String PHRASE_PLAN_END_DAY = "phrase_plan_end_day";
		/**
		 * 学习词组每天个数，选择每天学习个数模式
		 */
		public String PHRASE_EVERY_DAY_NUMBER = "phrase_every_day_number";
		/**
		 * 词组书是否正在学
		 */
		public String IS_LEARNING_PHRASE_BOOK = "is_learning_phrase_book";
		/**
		 * 巩固熟词模式
		 */
		public String CONSOLIDATE_MODE = "CONSOLIDATE_MODE";
		/**
		 * 是否初始化过数据库，针对words_log表的最后4列混乱的情况
		 */
		public String DID_FIX_WORDS_LOG_TABLE = "DID_FIX_WORDS_LOG_TABLE";
	}

	public interface StudyMode {
		/**
		 * 设置结束时间
		 */
		public int MODE_END_TIME = 1;
		/**
		 * 设置每天学习个数
		 */
		public int MODE_NUMBER = 2;
	}

	public interface BookType {
		/**
		 * 单词书
		 */
		public int BOOK_WORD = 1;
		/**
		 * 词组书
		 */
		public int BOOK_PHRASE = 2;
	}

	/**
	 * 单词熟悉度
	 * */
	public interface WordsFmDegree {
		public String[] wordsFmDegree = new String[] { "words_fm_degree0", "words_fm_degree1", "words_fm_degree2", "words_fm_degree3", "words_fm_degree4", "words_fm_degree5", "words_fm_degree6" };

		public String[] newWordsFmDegree = new String[] { "new_words_fm_degree0", "new_words_fm_degree1", "new_words_fm_degree2", "new_words_fm_degree3", "new_words_fm_degree4",
				"new_words_fm_degree5", "new_words_fm_degree6" };
	}

	/**
	 * 列表类型
	 * 
	 */
	public interface WordListType {
		/**
		 * 生词列表
		 */
		public int LIST_TYPE_UNFAMILIAR = 1;
		/**
		 * 普通单词列表
		 */
		public int LIST_TYPE_NORMAL = 2;
		/**
		 * 熟词列表
		 */
		public int LIST_TYPE_FAMILIAR = 3;
	}

	/**
	 * 单词列表的排序类型
	 * 
	 */
	public interface WordListSortValue {
		/**
		 * 按时间排序
		 */
		public int DATE = 0;
		/**
		 * 按字母排序
		 */
		public int CHARACTER = 1;
	}

	/**
	 * 单词列表的排序类型
	 * 
	 */
	public interface HuanboInterval {
		/**
		 * 环播的时间间隔
		 */
		public String HUANBO_INTERVAL[] = { "间隔1秒", "间隔2秒", "间隔3秒", "间隔4秒", "间隔5秒" };
		public int HUANBO_INTERVAL_MILLISECOND[] = { 1000, 2000, 3000, 4000, 5000 };
	}

	public interface Book {
		/**
		 * 单词数编号
		 */
		// public String BOOK_NAME[] = { "CET4单词", "CET6单词", "考研单词",
		// "高考必备单词","成人高考单词","专升本单词", "高中单词", "中考必备单词", "雅思单词",
		// "托福单词","TEM-4单词",
		// "新概念第一册单词", "新概念第二册单词", "新概念第三册单词", "新概念第四册单词","CET4高频单词",
		// "CET6高频单词", "考研高频单词", "中考必备词组", "高考必备词组","中考必备单词与词组",
		// "高考必备单词与词组","TEM-8单词", "人教版七年级下", "外研社版七年级下","牛津译林版七年级下",
		// "牛津上海版七年级下","牛津深圳版七年级下","冀教版七年级下", "仁爱版七年级下","北师大版七年级下",
		// "人教版八年级下", "外研社版八年级下", "牛津译林版八年级下","牛津上海版八年级下","牛津深圳版八年级下",
		// "冀教版八年级下", "仁爱版八年级下", "北师大版八年级下", "人教版九年级下","外研社版九年级下",
		// "牛津译林版九年级下","牛津上海版九年级下","牛津深圳版九年级下","仁爱版九年级下","人教版英语必修2",
		// "外研社版必修3、必修4", "牛津译林版英语模块3、4", "牛津上海版高一下", "北师版必修模块2","人教版英语必修4",
		// "外研模块5", "牛津译林版英语模块7、8", "牛津上海版高二下", "北师版必修模块4","牛津译林版英语模块11",
		// "牛津上海版高三下"，"北师七上","北师八上","鲁教七上","鲁教七下"
		// "鲁教八上","鲁教八下"，“鲁教九”，“牛津上海七上”，“牛津上海八上”，“牛津上海九上”，“牛津深圳七上”，“牛津深圳八上”，“牛津深圳九上”，“牛津译林七上”，
		// “牛津译林八上”，“牛津译林九上”,"人教七上"，“人教八上”，“仁爱七上”，“仁爱八上”，“仁爱九上”，“外研七上”，“外研八上”，“外研九上”，
		// “冀教七上”，“北师大模块1”，“北师大模块3”，“北师大模块5”，“牛津译林模块1，2”，“牛津译林模块5，6”，“牛津译林模块9，10”，“牛津上海高一上”，“牛津上海高二上”，“牛津上海高三上”
		// "人教模块1"，“人教模块3”，“人教模块5”，“外研模块1”，“新世纪高一上”，“新世纪高一下”，“新世纪高二上”，“新世纪高二下”，“新世纪高三上”，“新世纪高三下”
		// "四级词组"，“四级单词+词组”，“考研词组”，“考研补充词组”，“考研单词+词组”，“六级词组”，“六级单词+词组”，“雅思词组”，“雅思单词+词组”，“托福词组”，“托福单词+词组”，“SAT“};
		public int BOOK_INDEX[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
				43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
				89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112 };
		public int BOOK_ID[] = { 30000110, 35000110, 32000110, 15000110, 13000110, 26000110, 10600110, 6300110, 50000110, 51000110, 52000110, 60100110, 60200110, 60300110, 60400110, 30800110,
				35800110, 32800110, 6500110, 15500110, 6600110, 15600110, 52500110, 5100110, 5100210, 5100310, 5100410, 5100510, 5100610, 5100710, 5100810, 5300110, 5300210, 5300310, 5300410,
				5300510, 5300610, 5300710, 5300810, 5400110, 5500210, 5500310, 5500410, 5500510, 5500710, 10100110, 10100210, 10100310, 10100410, 10100810, 10300110, 10200210, 10300310, 10300410,
				10300810, 10500310, 10500410, 5000810, 5200810, 5001210, 5101210, 5201210, 5301210, 5401210, 5000410, 5200410, 5400410, 5000510, 5200510, 5400510, 5000310, 5200310, 5400310, 5000110,
				5200110, 5000710, 5200710, 5400710, 5000210, 5200210, 5400210, 5000610, 10000810, 10200810, 10400810, 10000310, 10200310, 10400310, 10000410, 10200410, 10400410, 10000110, 10200110,
				10400110, 10000210, 10001110, 10101110, 10201110, 10301110, 10401110, 10501110, 30500110, 30700110, 32500110, 32600110, 32700110, 35500110, 35700110, 50500110, 50700110, 51500110,
				51700110, 53510110 };
		public int BOOK_IMG[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, R.drawable.book_renjiao_7_down, R.drawable.book_waiyan_7_down,
				R.drawable.book_niujin_yilin_7_down, R.drawable.book_niujin_shanghai_7_down, R.drawable.book_niujin_shenzhen_7_down, R.drawable.book_yijiao_7_down, R.drawable.book_renai_7_down,
				R.drawable.book_beishida_7_down, R.drawable.book_renjiao_8_down, R.drawable.book_waiyan_8_down, R.drawable.book_niujin_yilin_8_down, R.drawable.book_niujin_shanghai_8_down,
				R.drawable.book_niujin_shenzhen_8_down, R.drawable.book_yijiao_8_down, R.drawable.book_renai_8_down, R.drawable.book_beishida_8_down, R.drawable.book_renjiao_9,
				R.drawable.book_waiyan_9_down, R.drawable.book_niujin_yilin_9_down, R.drawable.book_niujin_shanghai_9_down, R.drawable.book_niujin_shenzhen_9_down, R.drawable.book_renai_9_down,

				R.drawable.book_renjiao_gao_2, R.drawable.book_waiyan_gao_3, R.drawable.book_niujin_yilin_gao_3, R.drawable.book_niujin_shanghai_10_down, R.drawable.book_beishida_gao_2,
				R.drawable.book_renjiao_gao_4, R.drawable.book_waiyan_gao_5, R.drawable.book_niujin_yilin_gao_7, R.drawable.book_niujin_shanghai_11_down, R.drawable.book_beishida_gao_4,
				R.drawable.book_niujin_yilin_gao_11, R.drawable.book_niujin_shanghai_12_down,

				R.drawable.book_beishida_7_up, R.drawable.book_beishida_8_up, R.drawable.book_lujiao_7_up, R.drawable.book_lujiao_7_down, R.drawable.book_lujiao_8_up, R.drawable.book_lujiao_8_down,
				R.drawable.book_lujiao_9, R.drawable.book_niujin_shanghai_7_up, R.drawable.book_niujin_shanghai_8_up, R.drawable.book_niujin_shanghai_9_up, R.drawable.book_niujin_shenzhen_7_up,
				R.drawable.book_niujin_shenzhen_8_up, R.drawable.book_niujin_shenzhen_9_up, R.drawable.book_niujin_yilin_7_up, R.drawable.book_niujin_yilin_8_up, R.drawable.book_niujin_yilin_9_up,
				R.drawable.book_renjiao_7_up, R.drawable.book_renjiao_8_up, R.drawable.book_renai_7_up, R.drawable.book_renai_8_up, R.drawable.book_renai_9_up, R.drawable.book_waiyan_7_up,
				R.drawable.book_waiyan_8_up, R.drawable.book_waiyan_9_up, R.drawable.book_yijiao_7_up,

				R.drawable.book_beishida_gao_1, R.drawable.book_beishida_gao_3, R.drawable.book_beishida_gao_5, R.drawable.book_niujin_yilin_gao_1, R.drawable.book_niujin_yilin_gao_5,
				R.drawable.book_niujin_yilin_gao_9, R.drawable.book_niujin_shanghai_10_up, R.drawable.book_niujin_shanghai_11_up, R.drawable.book_niujin_shanghai_12_up, R.drawable.book_renjiao_gao_1,
				R.drawable.book_renjiao_gao_3, R.drawable.book_renjiao_gao_5, R.drawable.book_waiyan_gao_1, R.drawable.book_xinshiji_10_up, R.drawable.book_xinshiji_10_down,
				R.drawable.book_xinshiji_11_up, R.drawable.book_xinshiji_11_down, R.drawable.book_xinshiji_12_up, R.drawable.book_xinshiji_12_down, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

		/**
		 * 出版社
		 */
		public String PUBLISH_NAME_JUNIOR[] = { "人教版 - 人民教育出版社", "外研版 - 外语教学与研究出版社", "牛津上海版 - 上海教育出版社", "牛津深圳版 - 上海教育出版社", "牛津译林版 - 译林出版社", "冀教版 - 河北教育出版社", "仁爱版 - 科学普及出版社", "北师大版 - 北京师范大学出版社",
				"鲁教版 - 山东教育出版社" };
		public String PUBLISH_NAME_SENIOR[] = { "人教版 - 人民教育出版社", "外研版 - 外语教学与研究出版社", "牛津版 - 译林出版社", "牛津上海版 - 上海教育出版社", "北师大版 - 北京师范大学出版社", "新世纪版 - 上海外语教育出版社" };

		public int PUBLISH_INDEX_JUNIOR[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
		public int PUBLISH_INDEX_SENIOR[] = { 0, 1, 2, 3, 4, 5 };

	}

	/**
	 * 取得某类型单词列表下的排序方式，默认返回按时间排序
	 * 
	 * @param context
	 * @param listType
	 *            单词列表类型
	 * @see WordListType
	 * @see WordListSortValue
	 * @return 返回排序类型WordListSortValue
	 */
	public static int getSortType(Context context, int listType) {
		return getSharedPreferences(context).getInt(AppPreferenceName.SORT_TYPE + listType, WordListSortValue.DATE);
	}

	/**
	 * 保存某类型单词列表的排序方式
	 * 
	 * @param context
	 * @param listType
	 *            单词列表类型
	 * @param sortType
	 *            该列表的排序类型
	 * @see WordListType
	 * @see WordListSortValue
	 */
	public static void setSortType(Context context, int listType, int sortType) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.SORT_TYPE + listType, sortType).commit();
	}

	public static boolean isRelationshipEnShow(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.IS_RELATIONSHIP_EN_SHOW, true);
	}

	public static void setRelationshipEnShow(Context context, boolean isShow) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.IS_RELATIONSHIP_EN_SHOW, isShow).commit();
	}

	public static boolean isRelationshipCnShow(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.IS_RELATIONSHIP_CN_SHOW, false);
	}

	public static void setRelationshipCnShow(Context context, boolean isShow) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.IS_RELATIONSHIP_CN_SHOW, isShow).commit();
	}

	public static boolean isStudyNotification(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.STUDY_NOTIFICATION, true);
	}

	public static void setStudyNotification(Context context, boolean studyNotification) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.STUDY_NOTIFICATION, studyNotification).commit();
	}

	public static boolean isAutoPronunciation(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.AUTO_PRONUNCIATION, true);
	}

	public static void setAutoPronunciation(Context context, boolean autoPronunciation) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.AUTO_PRONUNCIATION, autoPronunciation).commit();
	}

	public static boolean hasSetStudyNotification(Context context) {
		return getSharedPreferences(context).contains(AppPreferenceName.STUDY_NOTIFICATION);
	}

	public static boolean isOpenSprintMode(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.SPRINT_MODE, false);
	}

	public static void setSprintMode(Context context, boolean studyNotification) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.SPRINT_MODE, studyNotification).commit();
	}

	public static boolean hasSetSprintMode(Context context) {
		return getSharedPreferences(context).contains(AppPreferenceName.SPRINT_MODE);
	}

	public static int getHuanboInterval(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.HUANBO_INTERVAL_INDEX, 0);
	}

	public static void setHuanboInterval(Context context, int huanboIntervalIndex) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.HUANBO_INTERVAL_INDEX, huanboIntervalIndex).commit();
	}

	public static String getBookName(Context context) {
		int index = getSharedPreferences(context).getInt(AppPreferenceName.BOOK_ID, -1);
		if (index == -1)
			return null;
		else
			return WordFactory.getInstance(context).getBookName(AppPreference.Book.BOOK_ID[index]);
	}

	public static boolean isFirstTimeStudyNewBook(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.FIRST_TIME_STUDY_NEW_BOOK, false);
	}

	public static void setFirstTimeStudyNewBook(Context context, boolean firstTimeStudyNewBook) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.FIRST_TIME_STUDY_NEW_BOOK, firstTimeStudyNewBook).commit();
	}

	public static int getPlanEndYear(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.PLAN_END_YEAR, -1);
	}

	public static void setPlanEndYear(Context context, int endYear) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.PLAN_END_YEAR, endYear).commit();
	}

	public static int getPlanEndMonth(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.PLAN_END_MONTH, -1);
	}

	public static void setPlanEndMonth(Context context, int endMonth) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.PLAN_END_MONTH, endMonth).commit();
	}

	public static int getPlanEndDay(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.PLAN_END_DAY, -1);
	}

	public static void setPlanEndDay(Context context, int endDay) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.PLAN_END_DAY, endDay).commit();
	}

	public static int getPlanStartDate(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.PLAN_START_DATE, 0);
	}

	public static void setPlanStartDate(Context context, int startDate) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.PLAN_START_DATE, startDate).commit();
	}

	public static void removePlanEndDate(Context context) {
		Editor editor = getSharedPreferences(context).edit();
		editor.remove(AppPreferenceName.WORD_PLAN_END_YEAR);
		editor.remove(AppPreferenceName.WORD_PLAN_END_MONTH);
		editor.remove(AppPreferenceName.WORD_PLAN_END_DAY);
		editor.commit();
	}

	public static int getLastTestStartTime(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.LAST_TEST_START_TIME, 0);
	}

	public static void setLastTestStartTime(Context context, int huanboIntervalIndex) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.LAST_TEST_START_TIME, huanboIntervalIndex).commit();
	}

	public static int getStudyDate(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.STUDY_DATE, -1);
	}

	public static void setStudyDate(Context context, int studyDate) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.STUDY_DATE, studyDate).commit();
	}

	public static int getReviewDate(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.REVIEW_DATE, -1);
	}

	public static void setReviewDate(Context context, int reviewDate) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.REVIEW_DATE, reviewDate).commit();
	}

	public static int getTodayStudyNewWordCount(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.TODAY_STUDY_NEW_WORD_COUNT, 0);
	}

	public static void setTodayStudyNewWordCount(Context context, int i) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.TODAY_STUDY_NEW_WORD_COUNT, i).commit();
	}

	public static int getTodayReviewWordCount(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.TODAY_REVIEW_WORD_COUNT, 0);
	}

	public static void setTodayReviewWordCount(Context context, int i) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.TODAY_REVIEW_WORD_COUNT, i).commit();
	}

	public static int getTodayShouldReviewWordCount(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.TODAY_SHOULD_REVIEW_WORD_COUNT, 0);
	}

	public static void setTodayShouldReviewWordCount(Context context, int i) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.TODAY_SHOULD_REVIEW_WORD_COUNT, i).commit();
	}

	public static int getAutoCheckUpdateDate(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.AUTO_CHECK_UPDATE_DATE, -1);
	}

	public static void setAutoCheckUpdateDate(Context context, int autoCheckUpdateDate) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.AUTO_CHECK_UPDATE_DATE, autoCheckUpdateDate).commit();
	}

	public static boolean isLockScreen(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.LOCK_SCREEN, true);
	}

	public static void setLockScreen(Context context, boolean b) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.LOCK_SCREEN, b).commit();
	}

	public static int getLockScreenWordsNum(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.LOCK_SCREEN_WORDS_NUM, 3);
	}

	public static void setLockScreenWordsNum(Context context, int lockScreenWordsNum) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.LOCK_SCREEN_WORDS_NUM, lockScreenWordsNum).commit();
	}

	public static String getNotificationRing(Context context) {
		String defaultNotificationRing = "android.resource://" + context.getPackageName() + "/" + R.raw.notify;
		return getSharedPreferences(context).getString(AppPreferenceName.CHOOSE_NOTIFICATION_RING, defaultNotificationRing);
	}

	public static void setNotificationRing(Context context, String stringUri) {
		getSharedPreferences(context).edit().putString(AppPreferenceName.CHOOSE_NOTIFICATION_RING, stringUri).commit();
	}

	public static String getLockScreenWallpaper(Context context) {
		return getSharedPreferences(context).getString(AppPreferenceName.LOCK_SCREEN_WALLPAPER, "default");
	}

	public static void setLockScreenWallpaper(Context context, String picName) {
		getSharedPreferences(context).edit().putString(AppPreferenceName.LOCK_SCREEN_WALLPAPER, picName).commit();
	}

	public static String getHeadPortrait(Context context) {
		return getSharedPreferences(context).getString(AppPreferenceName.HEAD_PORTRAIT_PIC, null);
	}

	public static void setHeadPortrait(Context context, String picName) {
		getSharedPreferences(context).edit().putString(AppPreferenceName.HEAD_PORTRAIT_PIC, picName).commit();
	}

	public static int getDefaultWallpaperImg(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.DEFAULT_WALLPAPER_IMG, R.drawable.lock_screen_bg0);
	}

	public static void setDefaultWallpaperImg(Context context, int img) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.DEFAULT_WALLPAPER_IMG, img).commit();
	}

	public static boolean isFirstVisitLockScreen(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.FIRST_VISIT_LOCK_SCREEN, true);
	}

	public static void setFirstVisitLockScreen(Context context, boolean b) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.FIRST_VISIT_LOCK_SCREEN, b).commit();
	}

	private static SharedPreferences getSharedPreferences(Context context) {
		return PreferenceManager.getDefaultSharedPreferences(context);
	}

	private static SharedPreferences getSharedPreferences(Context context, String prefName) {
		if (TextUtils.isEmpty(prefName)) {
			return PreferenceManager.getDefaultSharedPreferences(context);
		} else {
			return context.getSharedPreferences(prefName, Context.MODE_PRIVATE);
		}
	}

	public static int getNewWordsFmDegree(Context context, int index) {
		return getSharedPreferences(context).getInt(WordsFmDegree.newWordsFmDegree[index], 0);
	}

	public static void setNewWordsFmDegree(Context context, int wordsNum, int index) {
		getSharedPreferences(context).edit().putInt(WordsFmDegree.newWordsFmDegree[index], wordsNum).commit();
	}

	public static int getWordsFmDegree(Context context, int index) {
		return getSharedPreferences(context).getInt(WordsFmDegree.wordsFmDegree[index], 0);
	}

	public static void setWordsFmDegree(Context context, int wordsNum, int index) {
		getSharedPreferences(context).edit().putInt(WordsFmDegree.wordsFmDegree[index], wordsNum).commit();
	}

	public static boolean getIsFirstUseThisVersion(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.FIRST_TIME_USE_THIS_VERSION, false);
	}

	public static void setIsFirstUseThisVersion(Context context, boolean flag) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.FIRST_TIME_USE_THIS_VERSION, flag).commit();
	}

	public static boolean isToShowRenameGuide(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.TEMP_GUIDE_FOR_RENAME_TO_ZHIMI, true);
	}

	public static void setToShowRenameGuide(Context context, boolean flag) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.TEMP_GUIDE_FOR_RENAME_TO_ZHIMI, flag).commit();
	}

	public static boolean isFirstShowGuideStuding(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.FIRST_SHOW_GUIDE_STUDYING, true);
	}

	public static void setFisrtShowGuideStuding(Context context, boolean flag) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.FIRST_SHOW_GUIDE_STUDYING, flag).commit();
	}

	public static boolean isShowSetToFamiliarHint(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.SHOW_SET_TO_FAMILIAR_HINT, false);
	}

	public static void setShowSetToFamiliarHint(Context context, boolean flag) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.SHOW_SET_TO_FAMILIAR_HINT, flag).commit();
	}

	public static boolean isShowSetToTooEasyHint(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.SHOW_SET_TO_TOO_EASY_HINT, false);
	}

	public static void setShowSetToTooEasyHint(Context context, boolean flag) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.SHOW_SET_TO_TOO_EASY_HINT, flag).commit();
	}

	/**
	 * 用户帐户，默认为"guest"，登录后为用户注册邮箱，注销后为""空字符串
	 */
	public static String getLoginID(Context context) {
		return getSharedPreferences(context).getString(AppPreferenceName.LOGIN_ID, "guest");
	}

	public static void setLoginID(Context context, String loginID) {
		getSharedPreferences(context).edit().putString(AppPreferenceName.LOGIN_ID, loginID).commit();
	}

	public static String getPassword(Context context) {
		return getSharedPreferences(context).getString(AppPreferenceName.PASSWORD, "");
	}

	public static void setPassword(Context context, String password) {
		getSharedPreferences(context).edit().putString(AppPreferenceName.PASSWORD, password).commit();
	}

	public static String getToken(Context context) {
		return getSharedPreferences(context).getString(AppPreferenceName.TOKEN, "");
	}

	public static void setToken(Context context, String token) {
		getSharedPreferences(context).edit().putString(AppPreferenceName.TOKEN, token).commit();
	}

	public static int getEXP(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.EXP, -1);
	}

	public static void setEXP(Context context, int exp) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.EXP, exp).commit();
	}

	public static boolean getEXPUpdated(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.EXP_UPDATED, true);
	}

	public static void setEXPUpdated(Context context, boolean b) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.EXP_UPDATED, b).commit();
	}

	// public static int getMoney(Context context) {
	// return getSharedPreferences(context).getInt(AppPreferenceName.MONEY, 0);
	// }
	//
	// public static void setMoney(Context context, int money) {
	// getSharedPreferences(context).edit().putInt(AppPreferenceName.MONEY,
	// money).commit();
	// }

	public static int getSyncVC(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.SYNC_VC, 0);
	}

	public static void setSyncVC(Context context, int vc) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.SYNC_VC, vc).commit();
	}

	public static long getSyncTime(Context context) {
		return getSharedPreferences(context).getLong(AppPreferenceName.SYNC_TIME, 0);
	}

	public static void setSyncTime(Context context, long time) {
		getSharedPreferences(context).edit().putLong(AppPreferenceName.SYNC_TIME, time).commit();
	}

	public static int getAutoSyncDateAfterStartup(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.AUTO_SYNC_DATE_AFTER_STARTUP, -1);
	}

	public static void setAutoSyncDateAfterStartup(Context context, int autoSyncDateAfterStartup) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.AUTO_SYNC_DATE_AFTER_STARTUP, autoSyncDateAfterStartup).commit();
	}

	public static int getIsFirstOpenThisDay(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.FIRST_OPEN_THIS_DAY, -1);
	}

	public static void setIsFirstOpenThisDay(Context context, int autoSyncDateAfterStartup) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.FIRST_OPEN_THIS_DAY, autoSyncDateAfterStartup).commit();
	}

	public static int getAutoSyncDateAfterStudy(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.AUTO_SYNC_DATE_AFTER_STUDY, -1);
	}

	public static void setAutoSyncDateAfterStudy(Context context, int autoSyncDateAfterStudy) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.AUTO_SYNC_DATE_AFTER_STUDY, autoSyncDateAfterStudy).commit();
	}

	public static boolean isShowSyncHint(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.SHOW_SYNC_HINT, false);
	}

	public static void setShowSyncHint(Context context, boolean flag) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.SHOW_SYNC_HINT, flag).commit();
	}

	public static boolean isShowRecommendZhimiListen(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.SHOW_RECOMMEND_ZHIMI_LISTEN, false);
	}

	public static void setShowRecommendZhimiListen(Context context, boolean flag) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.SHOW_RECOMMEND_ZHIMI_LISTEN, flag).commit();
	}

	public static int getAutoCheckLoginDate(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.AUTO_CHECK_LOGIN_DATE, -1);
	}

	public static void setAutoCheckLoginDate(Context context, int autoCheckLoginDate) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.AUTO_CHECK_LOGIN_DATE, autoCheckLoginDate).commit();
	}

	public static void setSinaUid(Context context, String uid) {
		getSharedPreferences(context).edit().putString(AppPreferenceName.SINA_UID, uid).commit();
	}

	public static String getSinaUid(Context context) {
		return getSharedPreferences(context).getString(AppPreferenceName.SINA_UID, "");
	}

	public static void setSinaExpiresIn(Context context, long expires_in) {
		getSharedPreferences(context).edit().putLong(AppPreferenceName.SINA_EXPIRES_IN, expires_in).commit();
	}

	public static long getSinaExpiresIn(Context context) {
		return getSharedPreferences(context).getLong(AppPreferenceName.SINA_EXPIRES_IN, 0);
	}

	public static void setSinaAccessToken(Context context, String access_token) {
		getSharedPreferences(context).edit().putString(AppPreferenceName.SINA_ACCESS_TOKEN, access_token).commit();
	}

	public static String getSinaAccessToken(Context context) {
		return getSharedPreferences(context).getString(AppPreferenceName.SINA_ACCESS_TOKEN, "");
	}

	public static boolean isHasFixedWordsLogTable(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.DID_FIX_WORDS_LOG_TABLE, false);
	}

	public static void setHasFixedWordsLogTable(Context context, boolean flag) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.DID_FIX_WORDS_LOG_TABLE, flag).commit();
	}

	// public static void addSelectedBookId(Context context, int book_id) {
	// String bookIds = getSelectedBookId(context);
	// if (bookIds == null) {
	// bookIds = book_id + "";
	// } else {
	// bookIds += "," + book_id;
	// }
	// getSharedPreferences(context).edit().putString(AppPreferenceName.SELECTED_BOOK_ID,
	// bookIds).commit();
	// System.out.println("在Preference中,bookIds:" + bookIds);
	// }
	//
	// public static String getSelectedBookId(Context context) {
	// return
	// getSharedPreferences(context).getString(AppPreferenceName.SELECTED_BOOK_ID,
	// null);
	// }

	// 清空选过的单词书数据
	public static void clearSelectedBookId(Context context) {
		getSharedPreferences(context).edit().putString(AppPreferenceName.SELECTED_BOOK_ID, null).commit();
	}

	public static int getOldDbVersion(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.OLD_DB_VERSION, 0);
	}

	public static void setOldDbVersion(Context context, int oldBbVersion) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.OLD_DB_VERSION, oldBbVersion).commit();
	}

	public static void setSchoolId(Context context, int school_id) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.SCHOOL_ID, school_id).commit();
	}

	public static int getSchoolId(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.SCHOOL_ID, -1);
	}

	public static void setSchoolName(Context context, String school_name) {
		getSharedPreferences(context).edit().putString(AppPreferenceName.SCHOOL_NAME, school_name).commit();
	}

	public static String getSchoolName(Context context) {
		return getSharedPreferences(context).getString(AppPreferenceName.SCHOOL_NAME, null);
	}

	public static void setAccessTokenWeibo(Context context, String str) {
		getSharedPreferences(context).edit().putString(AppPreferenceName.ACCESS_TOKEN_WEIBO, str).commit();
	}

	public static String getAccessTokenWeibo(Context context) {
		return getSharedPreferences(context).getString(AppPreferenceName.ACCESS_TOKEN_WEIBO, null);
	}

	public static String getWeChatUnionid(Context context) {
		return getSharedPreferences(context).getString(AppPreferenceName.WECHAT_UNIONID, null);
	}

	public static void setWeChatUnionid(Context context, String str) {
		getSharedPreferences(context).edit().putString(AppPreferenceName.WECHAT_UNIONID, str).commit();
	}

	public static void setNickName(Context context, String str) {
		getSharedPreferences(context).edit().putString(AppPreferenceName.NICK_NAME, str).commit();
	}

	public static String getNickName(Context context) {
		// 如果是注册用户，且昵称为null，将昵称设置为loginID
		if (UserInterface.getInstance(context).isLogin() && getSharedPreferences(context).getString(AppPreferenceName.NICK_NAME, null) == null)
			setNickName(context, getLoginID(context));
		return getSharedPreferences(context).getString(AppPreferenceName.NICK_NAME, null);
	}

	public static String getWeChatOpenid(Context context) {
		return getSharedPreferences(context).getString(AppPreferenceName.WECHAT_OPENID, null);
	}

	public static void setWeChatOpenid(Context context, String str) {
		getSharedPreferences(context).edit().putString(AppPreferenceName.WECHAT_OPENID, str).commit();
	}

	public static boolean isFirstGuidePage(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.FIRST_GUIDE_PAGE2, true);
	}

	public static void setFirstGuidePage(Context context, boolean b) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.FIRST_GUIDE_PAGE2, b).commit();
	}

	public static boolean isDownloadPunchData(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.DOWNLOAD_PUNCH_DATA, false);
	}

	public static void setDownloadPunchData(Context context, boolean flag) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.DOWNLOAD_PUNCH_DATA, flag).commit();
	}

	public static boolean isInitForConsolidate(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.INIT_FOR_CONSOLIDATE, false);
	}

	public static void setInitForConsolidate(Context context, boolean flag) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.INIT_FOR_CONSOLIDATE, flag).commit();
	}

	public static int getFeedBackCount(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.FEED_BACK_COUNT, 0);
	}

	public static void setFeedBackCount(Context context) {
		int count = getFeedBackCount(context);
		getSharedPreferences(context).edit().putInt(AppPreferenceName.FEED_BACK_COUNT, count + 1).commit();
	}

	public static void clearFeedBackCount(Context context) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.FEED_BACK_COUNT, 0).commit();
	}

	public static boolean isToadyFeedBack(Context context, int date) {
		int feedbackDate = getSharedPreferences(context).getInt(AppPreferenceName.FEED_BACK_DATE, DateTimeUtils.getDate());
		if (feedbackDate == date) {
			return true;
		} else {
			clearFeedBackCount(context);
			return false;
		}
	}

	public static void setFeedBackDate(Context context, int date) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.FEED_BACK_DATE, date).commit();
	}

	public static void setADSPriority(Context context, String s) {
		getSharedPreferences(context).edit().putString(AppPreferenceName.WELCOME_ADS_PRIORITY, s).commit();
	}

	public static String getADSPriority(Context context) {
		return getSharedPreferences(context).getString(AppPreferenceName.WELCOME_ADS_PRIORITY, null);
	}

	public static void setADs1(Context context, String s) {
		getSharedPreferences(context).edit().putString(AppPreferenceName.WELCOME_ADS1, s).commit();
	}

	public static String getADs1(Context context) {
		return getSharedPreferences(context).getString(AppPreferenceName.WELCOME_ADS1, null);
	}

	public static void setADs2(Context context, String s) {
		getSharedPreferences(context).edit().putString(AppPreferenceName.WELCOME_ADS2, s).commit();
	}

	public static String getADs2(Context context) {
		return getSharedPreferences(context).getString(AppPreferenceName.WELCOME_ADS2, null);
	}

	public static void setADs3(Context context, String s) {
		getSharedPreferences(context).edit().putString(AppPreferenceName.WELCOME_ADS3, s).commit();
	}

	public static String getADs3(Context context) {
		return getSharedPreferences(context).getString(AppPreferenceName.WELCOME_ADS3, null);
	}

	public static boolean isHasFeedback(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.HAS_FEEDBACK, false);
	}

	public static void setHasFeedback(Context context, boolean hasFeedback) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.HAS_FEEDBACK, hasFeedback).commit();
	}

	public static void setSaveFeedback(Context context, String feedback) {
		getSharedPreferences(context).edit().putString(AppPreferenceName.SAVE_FEEDBACK, feedback).commit();
	}

	public static String getSaveFeedback(Context context) {
		return getSharedPreferences(context).getString(AppPreferenceName.SAVE_FEEDBACK, "");
	}

	public static int getDayNightMode(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.DAY_NIGHT_MODE, NightModeUtil.THEME_SUN);
	}

	public static void setDayNightMode(Context context, int dayNightMode) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.DAY_NIGHT_MODE, dayNightMode).commit();
	}

	public static String getNoPunchDate(Context mContext) {
		return getSharedPreferences(mContext).getString(AppPreferenceName.NO_PUNCH_DATE, "");
	}

	public static void addNoPunchDate(Context mContext, String noPunchDate) {
		LogUtil.d("添加未打卡日期：" + noPunchDate);
		String noPunchDateStr = getNoPunchDate(mContext);
		if (!noPunchDateStr.contains(noPunchDate)) {
			noPunchDateStr += noPunchDate + ";";
			String[] arr = noPunchDateStr.split(";");
			if (arr.length >= 3) {
				noPunchDateStr = noPunchDateStr.substring(noPunchDateStr.indexOf(";") + 1, noPunchDateStr.length());
			}
			LogUtil.d("所有未打卡日期：" + noPunchDateStr);
			getSharedPreferences(mContext).edit().putString(AppPreferenceName.NO_PUNCH_DATE, noPunchDateStr).commit();
		}
	}

	public static void setNoPunchDate(Context mContext, String noPunchDate) {
		LogUtil.d(noPunchDate);
		getSharedPreferences(mContext).edit().putString(AppPreferenceName.NO_PUNCH_DATE, noPunchDate).commit();
	}

	public static void removeRePunchDate(Context mContext, State state) {
		String noPunchDateStr = getNoPunchDate(mContext);
		LogUtil.d(noPunchDateStr);
		String[] arr = noPunchDateStr.split(";");
		if (arr.length == 1) {
			noPunchDateStr = "";
		} else if (arr.length == 2) {
			int arr0 = Integer.valueOf(arr[0]);
			int arr1 = Integer.valueOf(arr[1]);

			if (state == State.YESTERDAY) { // 去掉日期小的
				if (arr0 < arr1) {
					noPunchDateStr = arr[1] + ";";
				} else {
					noPunchDateStr = arr[0] + ";";
				}
			} else if (state == State.TODAY) { // 去掉日期大的
				if (arr0 < arr1) {
					noPunchDateStr = arr[0] + ";";
				} else {
					noPunchDateStr = arr[1] + ";";
				}
			}
		}
		setNoPunchDate(mContext, noPunchDateStr);
	}

	/**
	 * 单词书index v2.11.0之前
	 * 
	 * @param context
	 * @return
	 */
	public static int getBook(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.BOOK_ID, -1);
	}

	public static void setBook(Context context, int bookID) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.BOOK_ID, bookID).commit();
	}

	public static boolean hasStudyingBook(Context context) {
		return getWordBookIndex(context) != -1 || getPhraseBookIndex(context) != -1;
	}

	/**
	 * 单词书index
	 * 
	 * @param context
	 * @return
	 */
	public static int getWordBookIndex(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.WORD_BOOK_INDEX, -1);
	}

	public static void setWordBookIndex(Context context, int wordBookIndex) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.WORD_BOOK_INDEX, wordBookIndex).commit();
	}

	/**
	 * 单词学习模式
	 * 
	 * @param context
	 * @return
	 */
	public static int getWordStudyMode(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.WORD_STUDY_MODE, -1);
	}

	public static void setWordStudyMode(Context context, int wordStudyMode) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.WORD_STUDY_MODE, wordStudyMode).commit();
	}

	/**
	 * 词组书index
	 * 
	 * @param context
	 * @return
	 */
	public static int getPhraseBookIndex(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.PHRASE_BOOK_INDEX, -1);
	}

	public static void setPhraseBookIndex(Context context, int phraseBookIndex) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.PHRASE_BOOK_INDEX, phraseBookIndex).commit();
	}

	/**
	 * 词组学习模式
	 * 
	 * @param context
	 * @return
	 */
	public static int getPhraseStudyMode(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.PHRASE_STUDY_MODE, -1);
	}

	public static void setPhraseStudyMode(Context context, int phraseStudyMode) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.PHRASE_STUDY_MODE, phraseStudyMode).commit();
	}

	/**
	 * 单词书学习开始时间
	 * 
	 * @param context
	 * @return
	 */
	public static int getWordPlanStartDate(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.WORD_START_PLAN_DATE, 0);
	}

	public static void setWordPlanStartDate(Context context, int startDate) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.WORD_START_PLAN_DATE, startDate).commit();
	}

	/**
	 * 词组学习开始时间
	 * 
	 * @param context
	 * @return
	 */
	public static int getPhrasePlanStartDate(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.PHRASE_START_PLAN_DATE, 0);
	}

	public static void setPhrasePlanStartDate(Context context, int startDate) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.PHRASE_START_PLAN_DATE, startDate).commit();
	}

	/**
	 * 单词结束时间
	 * 
	 * @param context
	 * @return
	 */
	public static int getWordPlanEndYear(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.WORD_PLAN_END_YEAR, -1);
	}

	public static void setWordPlanEndYear(Context context, int endYear) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.WORD_PLAN_END_YEAR, endYear).commit();
	}

	public static int getWordPlanEndMonth(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.WORD_PLAN_END_MONTH, -1);
	}

	public static void setWordPlanEndMonth(Context context, int endMonth) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.WORD_PLAN_END_MONTH, endMonth).commit();
	}

	public static int getWordPlanEndDay(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.WORD_PLAN_END_DAY, -1);
	}

	public static void setWordPlanEndDay(Context context, int endDay) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.WORD_PLAN_END_DAY, endDay).commit();
	}

	/**
	 * 词组结束时间
	 * 
	 * @param context
	 * @return
	 */
	public static int getPhrasePlanEndYear(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.PHRASE_PLAN_END_YEAR, -1);
	}

	public static void setPhrasePlanEndYear(Context context, int endYear) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.PHRASE_PLAN_END_YEAR, endYear).commit();
	}

	public static int getPhrasePlanEndMonth(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.PHRASE_PLAN_END_MONTH, -1);
	}

	public static void setPhrasePlanEndMonth(Context context, int endMonth) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.PHRASE_PLAN_END_MONTH, endMonth).commit();
	}

	public static int getPhrasePlanEndDay(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.PHRASE_PLAN_END_DAY, -1);
	}

	public static void setPhrasePlanEndDay(Context context, int endDay) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.PHRASE_PLAN_END_DAY, endDay).commit();
	}

	/**
	 * 每天学习单词个数
	 * 
	 * @param context
	 * @return
	 */
	public static int getWordEveryDayNumber(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.WORD_EVERY_DAY_NUMBER, -1);
	}

	public static void setWordEveryDayNumber(Context context, int wordEveryDayNumber) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.WORD_EVERY_DAY_NUMBER, wordEveryDayNumber).commit();
	}

	/**
	 * 每天学习词组个数
	 * 
	 * @param context
	 * @return
	 */
	public static int getPhraseEveryDayNumber(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.PHRASE_EVERY_DAY_NUMBER, -1);
	}

	public static void setPhraseEveryDayNumber(Context context, int phraseEveryDayNumber) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.PHRASE_EVERY_DAY_NUMBER, phraseEveryDayNumber).commit();
	}

	/**
	 * 单词书学习计划是否正在学习
	 * 
	 * @param context
	 * @return
	 */
	public static boolean getWordBookIsLearning(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.IS_LEARNING_WORD_BOOK, true);
	}

	public static void setWordBookIsLearning(Context context, boolean isLearningWordBook) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.IS_LEARNING_WORD_BOOK, isLearningWordBook).commit();
	}

	/**
	 * 词组书学习计划是否正在学习
	 * 
	 * @param context
	 * @return
	 */
	public static boolean getPhraseBookIsLearning(Context context) {
		return getSharedPreferences(context).getBoolean(AppPreferenceName.IS_LEARNING_PHRASE_BOOK, true);
	}

	public static void setPhraseBookIsLearning(Context context, boolean isLearningPhraseBook) {
		getSharedPreferences(context).edit().putBoolean(AppPreferenceName.IS_LEARNING_PHRASE_BOOK, isLearningPhraseBook).commit();
	}

	/**
	 * 用户选择的巩固熟词的模式
	 * 
	 * @param context
	 * @return
	 */

	public static int getConsolidateMode(Context context) {
		return getSharedPreferences(context).getInt(AppPreferenceName.CONSOLIDATE_MODE, -1);
	}

	public static void setConsolidateMode(Context context, int mode) {
		getSharedPreferences(context).edit().putInt(AppPreferenceName.CONSOLIDATE_MODE, mode).commit();
	}

}
